#ifndef RENDERWIDGET_H
#define RENDERWIDGET_H

#include <QOpenGLWidget>
#include <QOpenGLShaderProgram>
#include <QOpenGLFunctions>

#include "xh_datadefine.h"

class renderWidget : public QOpenGLWidget, protected QOpenGLFunctions
{
    Q_OBJECT
public:
    explicit renderWidget(QWidget *parent = nullptr);
    ~renderWidget();

    void RendVideo(H264YUV_Frame* frame);

protected:
    void initializeGL() ;
    void resizeGL(int w, int h) ;
    void paintGL();

signals:

public slots:


private:
    bool   m_bUpdateData = false;
    QOpenGLShaderProgram *m_pShaderProgram = nullptr;
    GLuint          m_textures[3];

    int m_nVideoW       =0; //视频分辨率宽
    int m_nVideoH       =0; //视频分辨率高
    int m_yFrameLength  =0;
    int m_uFrameLength  =0;
    int m_vFrameLength  =0;

    unsigned char* m_pBufYuv420p = nullptr;

    struct XH_Vertex{
        float x,y,z;
        float u,v;
    };
};

#endif // RENDERWIDGET_H
